<?php

namespace App\Http\Model;

use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Redis;

class MqExceptionRecord extends Base
{
    protected $table = 'mq_exception_record';


    public function __construct(array $attributes = [])
    {
        parent::__construct($this->table, $attributes);
    }

    /**
     * 读取一批数据
     *
     * @return array
     * */
    public function getDataList($limit)
    {
        $getData = DB::table($this->table)
            ->where('status', 0)
            ->orderBy('id')
            ->offset(0)
            ->limit($limit)
            ->get(['id', 'data']);
        $data = self::objToArray($getData);
        return $data;
    }

    /**
     * 更新状态
     * @param $id int id
     * @param $result string 处理结果
     * */
    public function updateStatusById($id,$result)
    {
        $data = [
            'status' => 1,
            'api_result' => $result,
        ];
        $ret = DB::table($this->table)->where(['id' => $id])->update($data);
        return $ret;
    }

}
